package cn.edu.zust.se.mapper.anno;

import cn.edu.zust.se.model.CreditCard;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author czg
 * @since 2022/11/9 11:20
 */
public interface CreditCardMapper {
    @Results(id="cardMap",value = {
            @Result(property = "id",column = "id"),
            @Result(property = "cardNo",column = "card_no"),
            @Result(property = "bankName",column = "bank_name"),
            @Result(property = "userId",column = "user_id"),
            @Result(property = "user",column = "user_id",
            one=@One(select = "cn.edu.zust.se.mapper.anno.UserMapper.getUserById"))
    })
    @Select("select * from t_credit_card where user_id=#{uid}")
    public List<CreditCard> getCardsByUser(int uid);
    @Select("select * from t_credit_card where id=#{cardId}")
    @ResultMap(value = "cardMap")
    public CreditCard getCardById(int cardId);
}
